<template>
    <a-radio-group size='default' button-style='solid' v-model:value='locale' @change='changeLocale'>
        <a-radio-button v-for='item in i18nStore.locales' :key='item.code' :value='item.code'>{{item.name}}</a-radio-button>
    </a-radio-group>
</template>

<script lang='ts' setup>
import { useI18nStore } from "@/store/i18n";
import { ref } from "vue";
   
    const i18nStore = useI18nStore()

    const locale = ref(i18nStore.locale)

    function changeLocale(v) {
        locale.value = v.target.value
        i18nStore.setLocale(v.target.value)
        window.location.reload()
    }
</script>